package designpattern.template.jdbc;

import designpattern.template.jdbc.dataobject.User;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class UserMapper extends JdbcTemplate{
    //获取人员列表
    public List<User> list(String sql) throws SQLException {
        return executeQuery(sql, new RowMapper<User>() {
            @Override
            public User mapRow(ResultSet resultSet) throws SQLException {
                return User.builder().userId(resultSet.getString("user_id"))
                        .uuid(resultSet.getString("uuid"))
                        .id(resultSet.getLong("id")).build();
            }
        });
    }
}
